package com.antt.cn.test2.uis.activities;

import android.app.UiModeManager;
import android.content.Context;
import android.support.v7.app.AppCompatDelegate;
import android.view.View;
import android.widget.Button;

import com.antt.cn.test2.R;
import com.antt.cn.test2.uis.base.BaseActivity;
import com.antt.cn.test2.utils.AntLog;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Ant on 2017/5/8  11:21
 * <p>
 * <p>
 *
 * @version 1.0.0
 * @auther Ant
 */

public class Test05 extends BaseActivity {

    private Button obt;
    private UiModeManager uimanager;

    @Override
    public void initView() {
        ButterKnife.bind(this);
        uimanager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
        obt = (Button) findViewById(R.id.ac_test05_obt1);


    }

    @Override
    public void initData() {
    }


    @Override
    public void initListener() {

    }

    @OnClick({R.id.ac_test05_obt1, R.id.ac_test05_obt2, R.id.ac_test05_obt3})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ac_test05_obt1:
                AntLog.i("Test night");
                uimanager.setNightMode(UiModeManager.MODE_NIGHT_NO);
                break;
            case R.id.ac_test05_obt2:
                AntLog.i("test day");
//                setEnableNightMode(true);
                uimanager.setNightMode(UiModeManager.MODE_NIGHT_YES);
                break;
            case R.id.ac_test05_obt3:
                getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
                break;
        }
    }

    @Override
    public int getLayoutId() {
        return R.layout.ac_test05_layout;
    }


    public void setEnableNightMode(boolean enableNight) {
        if (enableNight) {
            getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        } else {
            getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }

        //recreate();
    }
}
